﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefPackageBank" :model="statePackageBank.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Sn_FormItem" prop="Entity.Sn" :label="$t('message.autotrans._Model_PackageBank_Sn')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_PackageBank_Sn')}), trigger: 'blur' }]" >
            <el-input v-model="statePackageBank.vmModel.Entity.Sn" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_WoId_FormItem" prop="Entity.WoId" :label="$t('message.autotrans._Model_PackageBank_WoId')">
            <el-input v-model="statePackageBank.vmModel.Entity.WoId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_WoCode_FormItem" prop="Entity.WoCode" :label="$t('message.autotrans._Model_PackageBank_WoCode')">
            <el-input v-model="statePackageBank.vmModel.Entity.WoCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductId_FormItem" prop="Entity.ProductId" :label="$t('message.autotrans._Model_PackageBank_ProductId')">
            <el-input v-model="statePackageBank.vmModel.Entity.ProductId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductName_FormItem" prop="Entity.ProductName" :label="$t('message.autotrans._Model_PackageBank_ProductName')">
            <el-input v-model="statePackageBank.vmModel.Entity.ProductName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StartTime_FormItem" prop="Entity.StartTime" :label="$t('message.autotrans._Model_PackageBank_StartTime')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_PackageBank_StartTime')}), trigger: 'blur' }]" >
            <el-input v-model="statePackageBank.vmModel.Entity.StartTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LastTime_FormItem" prop="Entity.LastTime" :label="$t('message.autotrans._Model_PackageBank_LastTime')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_PackageBank_LastTime')}), trigger: 'blur' }]" >
            <el-input v-model="statePackageBank.vmModel.Entity.LastTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LastSn_FormItem" prop="Entity.LastSn" :label="$t('message.autotrans._Model_PackageBank_LastSn')">
            <el-input v-model="statePackageBank.vmModel.Entity.LastSn" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CurrentCount_FormItem" prop="Entity.CurrentCount" :label="$t('message.autotrans._Model_PackageBank_CurrentCount')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_PackageBank_CurrentCount')}), trigger: 'blur' }]" >
            <el-input v-model="statePackageBank.vmModel.Entity.CurrentCount" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Qty_FormItem" prop="Entity.Qty" :label="$t('message.autotrans._Model_PackageBank_Qty')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_PackageBank_Qty')}), trigger: 'blur' }]" >
            <el-input v-model="statePackageBank.vmModel.Entity.Qty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <WtmTable ref="tableRefPackageRecordPackageList2" v-bind="tableDataPackageRecordPackageList2" v-model="statePackageBank.vmModel.Entity.PackageRecord_Package" disabled></WtmTable>
      <div style="text-align:right;">
        <WtmButton @click="onClosePackageBank"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PagePackageManagementPackageBankDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { packagebankApi } from '/@/api/packagemanagement/packagebank';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const tableRefPackageRecordPackageList2 = ref();
const tableDataPackageRecordPackageList2 = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page产品条码'),key: 'PartSn',type: 'textbox',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page首次装箱时间'),key: 'StartTime',type: 'date',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminRemark'),key: 'Remark',type: 'textbox',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: false, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
        isSub:true,
        isDisabled:true
	}
});

// 定义变量内容
const formRefPackageBank = ref();
const statePackageBank = reactive({
    vmModel: {
	  Entity:{
        Sn: '',
        WoId: null,
        WoCode: '',
        ProductId: null,
        ProductName: '',
        StartTime: undefined,
        LastTime: '',
        LastSn: '',
        CurrentCount: null,
        Qty: null,
        PackageRecord_Package:[],
        ID:null,
      },

	},
    
    AllPackages: [] as any[],
});

// 取消
const onClosePackageBank = () => {
    closeDialog();
};

// 提交
const onSubmitPackageBank = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefPackageBank.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            packagebankApi().edit(statePackageBank.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/PackageManagement/PackageRecord/GetPackageBanks',[],false).then(x=>{statePackageBank.AllPackages = x});
    if (ci.attrs["wtmdata"]) {
		statePackageBank.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		statePackageBank.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	packagebankApi().get(statePackageBank.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(statePackageBank.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

